function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) { return pair[1]; }
    }
    return (false);
}

function renderTable(params) {
    let table = params.table
    let result = params.result
    return table.render({
        elem: params.id,
        data: result.obj[params.data],
        cols: [
            [
                { field: 'name', width: '25%', title: '附件名称', align: "center" },
                { field: 'upload_time', width: '25%', title: '上传时间', align: "center" },
                { field: 'upload_by', width: '25%', title: '上传用户', align: "center" },
                { title: '操作', width: '25%', toolbar: params.tool, align: "left" }
            ]
        ],
        id: params.id,
        page: false,
        skin: 'line',
        done: function(res, curr, count) {
            console.log('------------------------------------------');
            console.log(res);
        }
    });
}

function downloadOrDelete(obj) {
    if (obj.event === 'download') { // 监听下载操作
        var aEle = document.createElement("a"); // 创建a标签
        aEle.href = publicurl + 'pro/downLoad?id=' + obj.data.id + '&fileName=' + obj.data.name;
        aEle.click(); // 设置点击事件
    } else if (obj.event === 'delete') { // 监听删除操作
        layer.confirm('是否删除？', function(index) {
            $.ajax({
                url: publicurl + 'pro/deleteJmEnclosure/',
                type: 'GET',
                data: {
                    id: obj.data.id
                },
                dataType: 'text',
                success: function(result) {
                    window.location.reload()
                }
            })
        });
    }
}